<template>
	<view>
		<scroll-view class="scroll-box" scroll-y>		
			<view class="member-box" v-for="(item,index) in memberList" :key="index">
				<membercard @shrinkTypeChange="shrinkTypeChange" :index="index" :info="item" :shrinkType="item.shrinkType"></membercard>
			</view>
			<view class="clearboth"></view>
		</scroll-view>
	</view>
</template>

<script>
	import * as api from '@/utils/api.js';
	import membercard from '../card/membercard.vue';
	export default {
		components:{
			membercard
		},
		props:{
			info:{
				type:Object,
				default:{}
			},
		},
		data() {
			return {
				apiinfo:{
					currentPage:1,
					pageSize:15,
					id:null,
				},
				memberList:[],// 成员列表
			}
		},
		mounted(){
			let info = this.info;
			let apiinfo = this.apiinfo;
			apiinfo.id = info.id;
			this.apiinfo = apiinfo;
			this.projectMemberList();
		},
		methods: {
			/**
			 * 项目成员列表
			 */
			projectMemberList:function(){
				let apiinfo = this.apiinfo;
				let memberList = this.memberList;
				api.projectMemberList(apiinfo).then(res=>{
					res.data.result.list.forEach(result=>{
						result.shrinkType = false;
					})
					memberList.push.apply(memberList,res.data.result.list);
					this.memberList = memberList;
				})
			},
			
			shrinkTypeChange:function(index){
				
				let memberList = this.memberList;
				this.$set(this.memberList[index],'shrinkType',!memberList[index].shrinkType);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.member-box{
		margin: 20rpx 0;
		
	}
	.scroll-box{
		width: 100%;
		height:calc(100vh - 230rpx);
	}
	.clearboth{
		height: 50rpx;
		width: 100%;
	}
</style>
